<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>

        function show(){
            let time = new Date()
            let str = time.getHours() + ":" +
                    time.getMinutes() + ":" +
                (time.getSeconds() < 10 ? '0'+time.getSeconds() : time.getSeconds())
            $('time').innerText = str
            //每秒调1次
            setTimeout('show()',1000)
        }

        //方法没有参数，可以不写（）
        //window.onload 窗体加载事件
        window.onload = show

        function $(id) {
            return document.getElementById(id)
        }



    </script>

</head>

<body>
    <div id="time"></div>
</body>
</html>
